import { ref, watchEffect } from "vue";
import { setsessionStorage, getsessionStorage } from "@/hooks/index";
export const routerHis = ref<
	Array<{
		value: string;
		path: string;
		parent: string;
		index: string;
	}>
>([
	{
		value: "首页",
		path: "/home/indexdefault",
		parent: "",
		index: "0",
	},
]);
/**
 * 记录header导航的活跃
 */
export let activ = ref<number>(0);
//页面刷新后获取之前的面包屑
getsessionStorage("HisActiv")
	? (activ.value = getsessionStorage("HisActiv"))
	: "";
getsessionStorage("addRouterHis")
	? (routerHis.value = getsessionStorage("addRouterHis"))
	: "";
//节流阀，页面刷新第一次不保存
let mark = false;
//当用户点击菜单将菜单存储
watchEffect(() => {
	console.log(activ.value);

	if (mark) {
		setsessionStorage("addRouterHis", routerHis.value);
		setsessionStorage("HisActiv", activ.value);
	}
	mark = true;
});
